<template>
	<view id="report">
		<view id="b1">
			<h2>税票分析报告</h2>
			<view id="sh">
				<h4>{{da(data,['baseinfoVo','tyshxydm'] )}}</h4>
			</view>
		</view>
		<van-tabs v-if="lock" v-model="active" animated duration='0.5'>
			<van-tab title="基本信息">
				<comJcxx :data="data"></comJcxx>
			</van-tab>
			<van-tab title="纳税信息">
				<comNsxx :data="data"></comNsxx>
			</van-tab>
			<van-tab title="发票信息">
				<comFpxx :data="data"></comFpxx>
			</van-tab>
			<van-tab title="供应商信息">
				<comGysxx :data="data"></comGysxx>
			</van-tab>
			<van-tab title="银税互动">
				<comYshd :data="data"></comYshd>
			</van-tab>
			<van-tab title="司法涉诉">
				<comSfss :data="data"></comSfss>
			</van-tab>
		</van-tabs>
	</view>
</template>

<script>
	import comJcxx from '@/components/com-jcxx.vue'
	import comNsxx from '@/components/com-nsxx.vue'
	import comFpxx from '@/components/com-fpxx.vue'
	import comGysxx from '@/components/com-gysxx.vue'
	import comYshd from '@/components/com-yshd.vue'
	import comSfss from '@/components/com-sfss.vue'
	import {
		comTemInfo
	} from '@/utils/comTemInfo.js'

	import {
		taxesResult
	} from '@/api/jinjian.js'

	export default {
		components: {
			comJcxx,
			comNsxx,
			comFpxx,
			comGysxx,
			comYshd,
			comSfss
		},
		data() {
			return {
				active: 0,
				orderNo: '示例报告001',
				lock: false,
				data: {}
			}
		},
		onLoad(options) {
			this.$modal.loading("正在查询.....")
			if (options.orderNo) {
				this.orderNo = options.orderNo
				taxesResult(this.orderNo).then(res => {
					if (res.code === 200) {
						this.data = res.data
						this.lock = true
					} else {
						this.$modal.alert(res.msg)
					}
					this.$modal.closeLoading()
				})
			} else {
				this.data = comTemInfo
				this.lock = true
				this.$modal.closeLoading()
			}
		},

		methods: {
			da(data, keys) {
				let i = 0
				while (i < keys.length) {
					if (data[keys[i]] == undefined) {
						return ''
					} else {
						data = data[keys[i]]
						i++
					}
				}
				return data == '' ? '' : data
			},
			goIndex() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
		}
	}
</script>
<style lang="scss" scoped>
	page {
		background: #fff;
		min-height: 100%;
	}
	#b1 {
		height: 16vh;
		background: url("../static/images/bg.png") no-repeat 0 0, #F5F6FC;
		background-size: cover;

		h2 {
			line-height: 9vh;
			text-align: center;
			color: #F5F6FC;
		}

		#sh {
			margin: 0 auto;
			background-color: #fff;
			width: 80%;
			height: 7vh;
			border-radius: 8px 8px 0 0;

			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>